//
//  CalculateTool.m
//  限时_自适应高度
//
//  Created by lanou3g on 16/6/16.
//  Copyright © 2016年 CG. All rights reserved.
//

#import "CalculateHighTool.h"

@implementation CalculateHighTool
+(CGFloat)heightForText:(NSString*)text andFontSize:(CGFloat)fontSize allowWidth:(CGFloat)lableWidth{
    CGRect rect =[text boundingRectWithSize:CGSizeMake(lableWidth, 10000) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontSize]} context:nil];
    return rect.size.height;
}
+(CGFloat)heightForImageName:(NSString*)imageName allowWidth:(CGFloat)imageWidth{
    if (imageName) {
        UIImage *image =[UIImage imageNamed:imageName];
        CGFloat width =image.size.width;
        CGFloat height = image.size.height;
        return height/width *imageWidth;
    }
    return 0;
}


@end
